class_name WeaponSystem
extends BaseSystem

#region 属性
@export var weapon_infos:Array[WeaponInfo]
var weapon_info_dict:Dictionary
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
func init_system(args = null):
	super(args)
	weapon_info_dict = {}
	for weapon_info in weapon_infos:
		if not weapon_info_dict.has(weapon_info.id):
			weapon_info_dict[weapon_info.id] = weapon_info
#endregion
#region 公共方法
func get_weapon_info(id:String) -> WeaponInfo:
	return weapon_info_dict[id] if weapon_info_dict.has(id) else null
func get_weapon(id:String) -> Weapon:
	if weapon_info_dict.has(id):
		var info:WeaponInfo = weapon_info_dict[id]
		var weapon:Weapon
		if info.scene:
			weapon = info.scene.instantiate()
			# 需要设置父对象
			GameWeaponSystem.add_child(weapon)
		return weapon
	else:
		return null
#endregion
#region 私有方法
#endregion
#region 生命周期函数
#endregion
